package fasilkom.antz.gui;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Transparency;
import java.awt.image.BufferedImage;

import com.golden.gamedev.gui.theme.basic.BTitleBarButtonRenderer;
import com.golden.gamedev.gui.toolkit.GraphicsUtil;
import com.golden.gamedev.gui.toolkit.TComponent;

public class CustomTitleBarButtonRenderer extends BTitleBarButtonRenderer {

	@Override
	public BufferedImage[] createUI(TComponent component, int w, int h) {
		BufferedImage[] ui = GraphicsUtil.createImage(4, w, h, Transparency.TRANSLUCENT);

		String[] color = new String[] {
			"Background Color", "Background Over Color",
			"Background Pressed Color", "Background Disabled Color"
		};

		Color borderColor = (Color) get("Background Border Color", component);
		for (int i=0;i < 4;i++) {
			Graphics2D g = ui[i].createGraphics();
			g.setColor((Color) get(color[i], component));
			switch (i) {
				case 0: g.fill3DRect(0, 0, w-1, h-1, true); break;
				case 1: g.fillRect(0, 0, w-1, h-1); break;
				case 2: g.fill3DRect(0, 0, w-1, h-1, false); break;
				case 3: g.fill3DRect(0, 0, w-1, h-1, true); break;
			}
			if (borderColor != null) {
				g.setColor(borderColor);
				g.drawRect(0, 0, w-1, h-1);
			}
			g.dispose();
		}

		return ui;
	}
}
